package my.study.demo.proxy.client;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Test03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int length = sc.nextInt();
        String goods = sc.nextLine();
        String types = sc.nextLine();
        int k = sc.nextInt();
        System.out.println(goods);
        List<Integer> goodList = Arrays.asList(goods.split("")).stream().map(Integer::valueOf).collect(Collectors.toList());
        List<Integer> typeList = Arrays.asList(types.split(" ")).stream().map(Integer::valueOf).collect(Collectors.toList());

        List<Integer> ganGoodList = new ArrayList<>();
        List<Integer> shiGoodList = new ArrayList<>();

        int ganLimit = 0;
        int shiLimit = 0;

        for (int i = 0; i < typeList.size(); i ++) {
            if(typeList.get(i) == 0) {
                ganGoodList.add(goodList.get(i));
            }else {
                shiGoodList.add(goodList.get(i));
            }
        }

        if(ganGoodList.size() == k) {
            ganLimit = ganGoodList.stream().mapToInt(value -> value).max().orElse(0);
        }
    }


}
